<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - scan_image_boxes.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2013  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#ifndef</font> DLIB_SCAN_IMAGE_bOXES_H__
<font color='#0000FF'>#define</font> DLIB_SCAN_IMAGE_bOXES_H__

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='scan_image_boxes_abstract.h.html'>scan_image_boxes_abstract.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../matrix.h.html'>../matrix.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../geometry.h.html'>../geometry.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../image_processing.h.html'>../image_processing.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../array2d.h.html'>../array2d.h</a>"
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>vector<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../image_processing/full_object_detection.h.html'>../image_processing/full_object_detection.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../image_transforms.h.html'>../image_transforms.h</a>"

<font color='#0000FF'>namespace</font> dlib
<b>{</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='default_box_generator'></a>default_box_generator</b>
    <b>{</b>
    <font color='#0000FF'>public</font>:
        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_type<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>void</u></font> <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> image_type<font color='#5555FF'>&amp;</font> img,
            std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> rects
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            rects.<font color='#BB00BB'>clear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>find_candidate_object_locations</font><font face='Lucida Console'>(</font>img, rects<font face='Lucida Console'>)</font>;
        <b>}</b>
    <b>}</b>;

    <font color='#0000FF'>inline</font> <font color='#0000FF'><u>void</u></font> <b><a name='serialize'></a>serialize</b><font face='Lucida Console'>(</font><font color='#0000FF'>const</font> default_box_generator<font color='#5555FF'>&amp;</font>, std::ostream<font color='#5555FF'>&amp;</font> <font face='Lucida Console'>)</font> <b>{</b><b>}</b>
    <font color='#0000FF'>inline</font> <font color='#0000FF'><u>void</u></font> <b><a name='deserialize'></a>deserialize</b><font face='Lucida Console'>(</font>default_box_generator<font color='#5555FF'>&amp;</font>, std::istream<font color='#5555FF'>&amp;</font> <font face='Lucida Console'>)</font> <b>{</b><b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> Feature_extractor_type,
        <font color='#0000FF'>typename</font> Box_generator <font color='#5555FF'>=</font> default_box_generator
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='scan_image_boxes'></a>scan_image_boxes</b> : noncopyable
    <b>{</b>

    <font color='#0000FF'>public</font>:

        <font color='#0000FF'>typedef</font> matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font> feature_vector_type;

        <font color='#0000FF'>typedef</font> Feature_extractor_type feature_extractor_type;
        <font color='#0000FF'>typedef</font> Box_generator box_generator;

        <b><a name='scan_image_boxes'></a>scan_image_boxes</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>;  

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
            <font color='#0000FF'>typename</font> image_type
            <font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>void</u></font> <b><a name='load'></a>load</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> image_type<font color='#5555FF'>&amp;</font> img
        <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>inline</font> <font color='#0000FF'><u>bool</u></font> <b><a name='is_loaded_with_image'></a>is_loaded_with_image</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;

        <font color='#0000FF'>inline</font> <font color='#0000FF'><u>void</u></font> <b><a name='copy_configuration'></a>copy_configuration</b><font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> feature_extractor_type<font color='#5555FF'>&amp;</font> fe
        <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>inline</font> <font color='#0000FF'><u>void</u></font> <b><a name='copy_configuration'></a>copy_configuration</b><font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> box_generator<font color='#5555FF'>&amp;</font> bg
        <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>const</font> box_generator<font color='#5555FF'>&amp;</font> <b><a name='get_box_generator'></a>get_box_generator</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> detect_boxes; <b>}</b> 

        <font color='#0000FF'>const</font> Feature_extractor_type<font color='#5555FF'>&amp;</font> <b><a name='get_feature_extractor'></a>get_feature_extractor</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> feats; <b>}</b>

        <font color='#0000FF'>inline</font> <font color='#0000FF'><u>void</u></font> <b><a name='copy_configuration'></a>copy_configuration</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> scan_image_boxes<font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>inline</font> <font color='#0000FF'><u>long</u></font> <b><a name='get_num_dimensions'></a>get_num_dimensions</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;

        <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> <b><a name='get_num_spatial_pyramid_levels'></a>get_num_spatial_pyramid_levels</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;

        <font color='#0000FF'><u>void</u></font> <b><a name='set_num_spatial_pyramid_levels'></a>set_num_spatial_pyramid_levels</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> levels
        <font face='Lucida Console'>)</font>;

        <font color='#0000FF'><u>void</u></font> <b><a name='detect'></a>detect</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> feature_vector_type<font color='#5555FF'>&amp;</font> w,
            std::vector<font color='#5555FF'>&lt;</font>std::pair<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>, rectangle<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> dets,
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> thresh
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;

        <font color='#0000FF'><u>void</u></font> <b><a name='get_feature_vector'></a>get_feature_vector</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> full_object_detection<font color='#5555FF'>&amp;</font> obj,
            feature_vector_type<font color='#5555FF'>&amp;</font> psi
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;

        full_object_detection <b><a name='get_full_object_detection'></a>get_full_object_detection</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> rect,
            <font color='#0000FF'>const</font> feature_vector_type<font color='#5555FF'>&amp;</font> w
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;

        <font color='#0000FF'>const</font> rectangle <b><a name='get_best_matching_rect'></a>get_best_matching_rect</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> rect
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            requires
                - is_loaded_with_image() == true
        !*/</font>

        <font color='#0000FF'>inline</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> <b><a name='get_num_detection_templates'></a>get_num_detection_templates</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#979000'>1</font>; <b>}</b>

        <font color='#0000FF'>inline</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> <b><a name='get_num_movable_components_per_detection_template'></a>get_num_movable_components_per_detection_template</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#979000'>0</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T, <font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'>friend</font> <font color='#0000FF'><u>void</u></font> <b><a name='serialize'></a>serialize</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> scan_image_boxes<font color='#5555FF'>&lt;</font>T,U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item,
            std::ostream<font color='#5555FF'>&amp;</font> out
        <font face='Lucida Console'>)</font>;

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T, <font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'>friend</font> <font color='#0000FF'><u>void</u></font> <b><a name='deserialize'></a>deserialize</b> <font face='Lucida Console'>(</font>
            scan_image_boxes<font color='#5555FF'>&lt;</font>T,U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item,
            std::istream<font color='#5555FF'>&amp;</font> in 
        <font face='Lucida Console'>)</font>;

    <font color='#0000FF'>private</font>:
        <font color='#0000FF'>static</font> <font color='#0000FF'><u>bool</u></font> <b><a name='compare_pair_rect'></a>compare_pair_rect</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> std::pair<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>, rectangle<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> a,
            <font color='#0000FF'>const</font> std::pair<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>, rectangle<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> b
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>return</font> a.first <font color='#5555FF'>&lt;</font> b.first;
        <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='test_coordinate_transforms'></a>test_coordinate_transforms</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> x <font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>10</font>; x <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>10</font>; x <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#979000'>10</font><font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> y <font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>10</font>; y <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>10</font>; y <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#979000'>10</font><font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#0000FF'>const</font> rectangle rect <font color='#5555FF'>=</font> <font color='#BB00BB'>centered_rect</font><font face='Lucida Console'>(</font>x,y,<font color='#979000'>5</font>,<font color='#979000'>6</font><font face='Lucida Console'>)</font>;
                    rectangle a;

                    a <font color='#5555FF'>=</font> feats.<font color='#BB00BB'>image_to_feat_space</font><font face='Lucida Console'>(</font>rect<font face='Lucida Console'>)</font>;
                    <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>a.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>  <font color='#5555FF'>&gt;</font> <font color='#979000'>10000000</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> a.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> <font color='#979000'>10000000</font> <font face='Lucida Console'>)</font>
                    <b>{</b>
                        <font color='#BB00BB'>DLIB_CASSERT</font><font face='Lucida Console'>(</font><font color='#979000'>false</font>, "<font color='#CC0000'>The image_to_feat_space() routine is outputting rectangles of an implausibly </font>"
                                     <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\nlarge size.  This means there is probably a bug in your feature extractor.</font>"<font face='Lucida Console'>)</font>;
                    <b>}</b>
                    a <font color='#5555FF'>=</font> feats.<font color='#BB00BB'>feat_to_image_space</font><font face='Lucida Console'>(</font>rect<font face='Lucida Console'>)</font>;
                    <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>a.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>  <font color='#5555FF'>&gt;</font> <font color='#979000'>10000000</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> a.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> <font color='#979000'>10000000</font> <font face='Lucida Console'>)</font>
                    <b>{</b>
                        <font color='#BB00BB'>DLIB_CASSERT</font><font face='Lucida Console'>(</font><font color='#979000'>false</font>, "<font color='#CC0000'>The feat_to_image_space() routine is outputting rectangles of an implausibly </font>"
                                     <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\nlarge size.  This means there is probably a bug in your feature extractor.</font>"<font face='Lucida Console'>)</font>;
                    <b>}</b>
                <b>}</b>
            <b>}</b>
            
        <b>}</b>

        <font color='#0000FF'>static</font> <font color='#0000FF'><u>void</u></font> <b><a name='add_grid_rects'></a>add_grid_rects</b> <font face='Lucida Console'>(</font>
            std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> rects,
            <font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> object_box,
            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> cells_x,
            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> cells_y
        <font face='Lucida Console'>)</font> 
        <b>{</b>
            <font color='#009900'>// make sure requires clause is not broken
</font>            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>cells_x <font color='#5555FF'>&gt;</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> cells_y <font color='#5555FF'>&gt;</font> <font color='#979000'>0</font>,
                "<font color='#CC0000'>\t void add_grid_rects()</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t The number of cells along a dimension can't be zero. </font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t cells_x: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> cells_x
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t cells_y: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> cells_y
            <font face='Lucida Console'>)</font>;

            <font color='#0000FF'>const</font> matrix_range_exp<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> x <font color='#5555FF'>=</font> <font color='#BB00BB'>linspace</font><font face='Lucida Console'>(</font>object_box.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, object_box.<font color='#BB00BB'>right</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, cells_x<font color='#5555FF'>+</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> matrix_range_exp<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> y <font color='#5555FF'>=</font> <font color='#BB00BB'>linspace</font><font face='Lucida Console'>(</font>object_box.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, object_box.<font color='#BB00BB'>bottom</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, cells_y<font color='#5555FF'>+</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;

            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j<font color='#5555FF'>+</font><font color='#979000'>1</font> <font color='#5555FF'>&lt;</font> y.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i<font color='#5555FF'>+</font><font color='#979000'>1</font> <font color='#5555FF'>&lt;</font> x.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#0000FF'>const</font> dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <font color='#BB00BB'>tl</font><font face='Lucida Console'>(</font><font color='#BB00BB'>x</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>,<font color='#BB00BB'>y</font><font face='Lucida Console'>(</font>j<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                    <font color='#0000FF'>const</font> dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <font color='#BB00BB'>br</font><font face='Lucida Console'>(</font><font color='#BB00BB'>x</font><font face='Lucida Console'>(</font>i<font color='#5555FF'>+</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>,<font color='#BB00BB'>y</font><font face='Lucida Console'>(</font>j<font color='#5555FF'>+</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                    rects.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font><font color='#BB00BB'>rectangle</font><font face='Lucida Console'>(</font>tl,br<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                <b>}</b>
            <b>}</b>
        <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='get_feature_extraction_regions'></a>get_feature_extraction_regions</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> rect,
            std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> regions
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <font color='#009900'>/*!
            ensures
                - #regions.size() is always the same number no matter what the input is.  The
                  regions also have a consistent ordering.
                - all the output rectangles are contained within rect.
        !*/</font>
        <b>{</b>
            regions.<font color='#BB00BB'>clear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> l <font color='#5555FF'>=</font> <font color='#979000'>1</font>; l <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> num_spatial_pyramid_levels; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>l<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>const</font> <font color='#0000FF'><u>int</u></font> cells <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>int</u></font><font face='Lucida Console'>)</font>std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font><font color='#979000'>2.0</font>, l<font color='#5555FF'>-</font><font color='#979000'>1.0</font><font face='Lucida Console'>)</font>;
                <font color='#BB00BB'>add_grid_rects</font><font face='Lucida Console'>(</font>regions, rect, cells, cells<font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>

        <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> <b><a name='get_num_components_per_detection_template'></a>get_num_components_per_detection_template</b><font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#0000FF'>return</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>pow</font><font face='Lucida Console'>(</font><font color='#979000'>4.0</font>,<font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font>num_spatial_pyramid_levels<font face='Lucida Console'>)</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font color='#979000'>3</font>;
        <b>}</b>

        feature_extractor_type feats;
        std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font> search_rects;
        <font color='#0000FF'><u>bool</u></font> loaded_with_image;
        <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>int</u></font> num_spatial_pyramid_levels;
        box_generator detect_boxes;

        <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> box_sizedims;
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> box_maxsize;
    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T, <font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='serialize'></a>serialize</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> scan_image_boxes<font color='#5555FF'>&lt;</font>T,U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item,
        std::ostream<font color='#5555FF'>&amp;</font> out
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'><u>int</u></font> version <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
        <font color='#BB00BB'>serialize</font><font face='Lucida Console'>(</font>version, out<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>serialize</font><font face='Lucida Console'>(</font>item.feats, out<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>serialize</font><font face='Lucida Console'>(</font>item.search_rects, out<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>serialize</font><font face='Lucida Console'>(</font>item.loaded_with_image, out<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>serialize</font><font face='Lucida Console'>(</font>item.num_spatial_pyramid_levels, out<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>serialize</font><font face='Lucida Console'>(</font>item.detect_boxes, out<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>serialize</font><font face='Lucida Console'>(</font>item.<font color='#BB00BB'>get_num_dimensions</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, out<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T, <font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='deserialize'></a>deserialize</b> <font face='Lucida Console'>(</font>
        scan_image_boxes<font color='#5555FF'>&lt;</font>T,U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item,
        std::istream<font color='#5555FF'>&amp;</font> in 
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'><u>int</u></font> version <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
        <font color='#BB00BB'>deserialize</font><font face='Lucida Console'>(</font>version, in<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>version <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font>
            <font color='#0000FF'>throw</font> <font color='#BB00BB'>serialization_error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unsupported version found when deserializing a scan_image_boxes object.</font>"<font face='Lucida Console'>)</font>;

        <font color='#BB00BB'>deserialize</font><font face='Lucida Console'>(</font>item.feats, in<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>deserialize</font><font face='Lucida Console'>(</font>item.search_rects, in<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>deserialize</font><font face='Lucida Console'>(</font>item.loaded_with_image, in<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>deserialize</font><font face='Lucida Console'>(</font>item.num_spatial_pyramid_levels, in<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>deserialize</font><font face='Lucida Console'>(</font>item.detect_boxes, in<font face='Lucida Console'>)</font>;

        <font color='#009900'>// When developing some feature extractor, it's easy to accidentally change its
</font>        <font color='#009900'>// number of dimensions and then try to deserialize data from an older version of
</font>        <font color='#009900'>// your extractor into the current code.  This check is here to catch that kind of
</font>        <font color='#009900'>// user error.
</font>        <font color='#0000FF'><u>long</u></font> dims;
        <font color='#BB00BB'>deserialize</font><font face='Lucida Console'>(</font>dims, in<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>item.<font color='#BB00BB'>get_num_dimensions</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> dims<font face='Lucida Console'>)</font>
            <font color='#0000FF'>throw</font> <font color='#BB00BB'>serialization_error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Number of dimensions in serialized scan_image_boxes doesn't match the expected number.</font>"<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>//                         scan_image_boxes member functions
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> Feature_extractor_type,
        <font color='#0000FF'>typename</font> Box_generator
        <font color='#5555FF'>&gt;</font>
    scan_image_boxes<font color='#5555FF'>&lt;</font>Feature_extractor_type,Box_generator<font color='#5555FF'>&gt;</font>::
    <b><a name='scan_image_boxes'></a>scan_image_boxes</b> <font face='Lucida Console'>(</font>
    <font face='Lucida Console'>)</font> :
        loaded_with_image<font face='Lucida Console'>(</font><font color='#979000'>false</font><font face='Lucida Console'>)</font>,
        num_spatial_pyramid_levels<font face='Lucida Console'>(</font><font color='#979000'>3</font><font face='Lucida Console'>)</font>,
        box_sizedims<font face='Lucida Console'>(</font><font color='#979000'>20</font><font face='Lucida Console'>)</font>,
        box_maxsize<font face='Lucida Console'>(</font><font color='#979000'>1200</font><font face='Lucida Console'>)</font>
    <b>{</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> Feature_extractor_type,
        <font color='#0000FF'>typename</font> Box_generator
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> image_type
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> scan_image_boxes<font color='#5555FF'>&lt;</font>Feature_extractor_type,Box_generator<font color='#5555FF'>&gt;</font>::
    <b><a name='load'></a>load</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> image_type<font color='#5555FF'>&amp;</font> img
    <font face='Lucida Console'>)</font>
    <b>{</b>
        feats.<font color='#BB00BB'>load</font><font face='Lucida Console'>(</font>img<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>detect_boxes</font><font face='Lucida Console'>(</font>img, search_rects<font face='Lucida Console'>)</font>;
        loaded_with_image <font color='#5555FF'>=</font> <font color='#979000'>true</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> Feature_extractor_type,
        <font color='#0000FF'>typename</font> Box_generator
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>bool</u></font> scan_image_boxes<font color='#5555FF'>&lt;</font>Feature_extractor_type,Box_generator<font color='#5555FF'>&gt;</font>::
    <b><a name='is_loaded_with_image'></a>is_loaded_with_image</b> <font face='Lucida Console'>(</font>
    <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
    <b>{</b>
        <font color='#0000FF'>return</font> loaded_with_image;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> Feature_extractor_type,
        <font color='#0000FF'>typename</font> Box_generator
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> scan_image_boxes<font color='#5555FF'>&lt;</font>Feature_extractor_type,Box_generator<font color='#5555FF'>&gt;</font>::
    <b><a name='copy_configuration'></a>copy_configuration</b><font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> feature_extractor_type<font color='#5555FF'>&amp;</font> fe
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#BB00BB'>test_coordinate_transforms</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        feats.<font color='#BB00BB'>copy_configuration</font><font face='Lucida Console'>(</font>fe<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> Feature_extractor_type,
        <font color='#0000FF'>typename</font> Box_generator
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> scan_image_boxes<font color='#5555FF'>&lt;</font>Feature_extractor_type,Box_generator<font color='#5555FF'>&gt;</font>::
    <b><a name='copy_configuration'></a>copy_configuration</b><font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> box_generator<font color='#5555FF'>&amp;</font> bg 
    <font face='Lucida Console'>)</font>
    <b>{</b>
        detect_boxes <font color='#5555FF'>=</font> bg;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> Feature_extractor_type,
        <font color='#0000FF'>typename</font> Box_generator
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> scan_image_boxes<font color='#5555FF'>&lt;</font>Feature_extractor_type,Box_generator<font color='#5555FF'>&gt;</font>::
    <b><a name='copy_configuration'></a>copy_configuration</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> scan_image_boxes<font color='#5555FF'>&amp;</font> item
    <font face='Lucida Console'>)</font>
    <b>{</b>
        feats.<font color='#BB00BB'>copy_configuration</font><font face='Lucida Console'>(</font>item.feats<font face='Lucida Console'>)</font>;
        detect_boxes <font color='#5555FF'>=</font> item.detect_boxes;
        num_spatial_pyramid_levels <font color='#5555FF'>=</font> item.num_spatial_pyramid_levels;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> Feature_extractor_type,
        <font color='#0000FF'>typename</font> Box_generator
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> scan_image_boxes<font color='#5555FF'>&lt;</font>Feature_extractor_type,Box_generator<font color='#5555FF'>&gt;</font>::
    <b><a name='get_num_spatial_pyramid_levels'></a>get_num_spatial_pyramid_levels</b> <font face='Lucida Console'>(</font>
    <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
    <b>{</b>
        <font color='#0000FF'>return</font> num_spatial_pyramid_levels;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> Feature_extractor_type,
        <font color='#0000FF'>typename</font> Box_generator
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> scan_image_boxes<font color='#5555FF'>&lt;</font>Feature_extractor_type,Box_generator<font color='#5555FF'>&gt;</font>::
    <b><a name='set_num_spatial_pyramid_levels'></a>set_num_spatial_pyramid_levels</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> levels
    <font face='Lucida Console'>)</font> 
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>levels <font color='#5555FF'>&gt;</font> <font color='#979000'>0</font>, 
            "<font color='#CC0000'>\t void scan_image_boxes::set_num_spatial_pyramid_levels()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function </font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t levels: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> levels 
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t this: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
            <font face='Lucida Console'>)</font>;
        

        num_spatial_pyramid_levels <font color='#5555FF'>=</font> levels;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> Feature_extractor_type,
        <font color='#0000FF'>typename</font> Box_generator
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>long</u></font> scan_image_boxes<font color='#5555FF'>&lt;</font>Feature_extractor_type,Box_generator<font color='#5555FF'>&gt;</font>::
    <b><a name='get_num_dimensions'></a>get_num_dimensions</b> <font face='Lucida Console'>(</font>
    <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
    <b>{</b>
        <font color='#0000FF'>return</font> feats.<font color='#BB00BB'>get_num_dimensions</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#BB00BB'>get_num_components_per_detection_template</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> box_sizedims<font color='#5555FF'>*</font><font color='#979000'>2</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> Feature_extractor_type,
        <font color='#0000FF'>typename</font> Box_generator
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> scan_image_boxes<font color='#5555FF'>&lt;</font>Feature_extractor_type,Box_generator<font color='#5555FF'>&gt;</font>::
    <b><a name='detect'></a>detect</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> feature_vector_type<font color='#5555FF'>&amp;</font> w,
        std::vector<font color='#5555FF'>&lt;</font>std::pair<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>, rectangle<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> dets,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> thresh
    <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font><font color='#BB00BB'>is_loaded_with_image</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                    w.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#BB00BB'>get_num_dimensions</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, 
            "<font color='#CC0000'>\t void scan_image_boxes::detect()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function </font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_loaded_with_image(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_loaded_with_image</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t w.size():               </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> w.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t get_num_dimensions():   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>get_num_dimensions</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t this: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
            <font face='Lucida Console'>)</font>;
        
        dets.<font color='#BB00BB'>clear</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        array<font color='#5555FF'>&lt;</font>integral_image_generic<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> <font color='#BB00BB'>saliency_images</font><font face='Lucida Console'>(</font><font color='#BB00BB'>get_num_components_per_detection_template</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

        array2d<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font> <font color='#BB00BB'>temp_img</font><font face='Lucida Console'>(</font>feats.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, feats.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

        <font color='#009900'>// build saliency images  
</font>        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> saliency_images.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> offset <font color='#5555FF'>=</font> <font color='#979000'>2</font><font color='#5555FF'>*</font>box_sizedims <font color='#5555FF'>+</font> feats.<font color='#BB00BB'>get_num_dimensions</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>i;

            <font color='#009900'>// make the basic saliency image for the i-th feature extraction region
</font>            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> <font color='#979000'>0</font>; r <font color='#5555FF'>&lt;</font> feats.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>0</font>; c <font color='#5555FF'>&lt;</font> feats.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> feature_extractor_type::descriptor_type<font color='#5555FF'>&amp;</font> descriptor <font color='#5555FF'>=</font> <font color='#BB00BB'>feats</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font>;

                    <font color='#0000FF'><u>double</u></font> sum <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
                    <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> k <font color='#5555FF'>=</font> <font color='#979000'>0</font>; k <font color='#5555FF'>&lt;</font> descriptor.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>k<font face='Lucida Console'>)</font>
                    <b>{</b>
                        sum <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>w</font><font face='Lucida Console'>(</font>descriptor[k].first <font color='#5555FF'>+</font> offset<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>descriptor[k].second;
                    <b>}</b>
                    temp_img[r][c] <font color='#5555FF'>=</font> sum;
                <b>}</b>
            <b>}</b>

            <font color='#009900'>// now convert base saliency image into final integral image
</font>            saliency_images[i].<font color='#BB00BB'>load</font><font face='Lucida Console'>(</font>temp_img<font face='Lucida Console'>)</font>;
        <b>}</b>


        <font color='#009900'>// now search the saliency images
</font>        std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font> regions;
        <font color='#0000FF'>const</font> rectangle bounds <font color='#5555FF'>=</font> <font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>feats<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> search_rects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>const</font> rectangle rect <font color='#5555FF'>=</font> feats.<font color='#BB00BB'>image_to_feat_space</font><font face='Lucida Console'>(</font>search_rects[i]<font face='Lucida Console'>)</font>.<font color='#BB00BB'>intersect</font><font face='Lucida Console'>(</font>bounds<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>rect.<font color='#BB00BB'>is_empty</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
                <font color='#0000FF'>continue</font>;
            <font color='#BB00BB'>get_feature_extraction_regions</font><font face='Lucida Console'>(</font>rect, regions<font face='Lucida Console'>)</font>;
            <font color='#0000FF'><u>double</u></font> score <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> k <font color='#5555FF'>=</font> <font color='#979000'>0</font>; k <font color='#5555FF'>&lt;</font> regions.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>k<font face='Lucida Console'>)</font>
            <b>{</b>
                score <font color='#5555FF'>+</font><font color='#5555FF'>=</font> saliency_images[k].<font color='#BB00BB'>get_sum_of_area</font><font face='Lucida Console'>(</font>regions[k]<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> width <font color='#5555FF'>=</font> search_rects[i].<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> height <font color='#5555FF'>=</font> search_rects[i].<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

            score <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>dot</font><font face='Lucida Console'>(</font><font color='#BB00BB'>linpiece</font><font face='Lucida Console'>(</font>width,  <font color='#BB00BB'>linspace</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>, box_maxsize, box_sizedims<font color='#5555FF'>+</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>, <font color='#BB00BB'>rowm</font><font face='Lucida Console'>(</font>w, <font color='#BB00BB'>range</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,box_sizedims<font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            score <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>dot</font><font face='Lucida Console'>(</font><font color='#BB00BB'>linpiece</font><font face='Lucida Console'>(</font>height, <font color='#BB00BB'>linspace</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>, box_maxsize, box_sizedims<font color='#5555FF'>+</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>, <font color='#BB00BB'>rowm</font><font face='Lucida Console'>(</font>w, <font color='#BB00BB'>range</font><font face='Lucida Console'>(</font>box_sizedims,<font color='#979000'>2</font><font color='#5555FF'>*</font>box_sizedims<font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>score <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> thresh<font face='Lucida Console'>)</font>
            <b>{</b>
                dets.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>std::<font color='#BB00BB'>make_pair</font><font face='Lucida Console'>(</font>score, search_rects[i]<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>

        std::<font color='#BB00BB'>sort</font><font face='Lucida Console'>(</font>dets.<font color='#BB00BB'>rbegin</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, dets.<font color='#BB00BB'>rend</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, compare_pair_rect<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> Feature_extractor_type,
        <font color='#0000FF'>typename</font> Box_generator
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>const</font> rectangle scan_image_boxes<font color='#5555FF'>&lt;</font>Feature_extractor_type,Box_generator<font color='#5555FF'>&gt;</font>::
    <b><a name='get_best_matching_rect'></a>get_best_matching_rect</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> rect
    <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font><font color='#BB00BB'>is_loaded_with_image</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
            "<font color='#CC0000'>\t const rectangle scan_image_boxes::get_best_matching_rect()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function </font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_loaded_with_image(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_loaded_with_image</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t this: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
            <font face='Lucida Console'>)</font>;


        <font color='#0000FF'><u>double</u></font> best_score <font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>1</font>;
        rectangle best_rect;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> search_rects.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> score <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>rect.<font color='#BB00BB'>intersect</font><font face='Lucida Console'>(</font>search_rects[i]<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>.<font color='#BB00BB'>area</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>/</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font>rect<font color='#5555FF'>+</font>search_rects[i]<font face='Lucida Console'>)</font>.<font color='#BB00BB'>area</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>score <font color='#5555FF'>&gt;</font> best_score<font face='Lucida Console'>)</font>
            <b>{</b>
                best_score <font color='#5555FF'>=</font> score;
                best_rect <font color='#5555FF'>=</font> search_rects[i];
            <b>}</b>
        <b>}</b>
        <font color='#0000FF'>return</font> best_rect;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> Feature_extractor_type,
        <font color='#0000FF'>typename</font> Box_generator
        <font color='#5555FF'>&gt;</font>
    full_object_detection scan_image_boxes<font color='#5555FF'>&lt;</font>Feature_extractor_type,Box_generator<font color='#5555FF'>&gt;</font>::
    <b><a name='get_full_object_detection'></a>get_full_object_detection</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> rect,
        <font color='#0000FF'>const</font> feature_vector_type<font color='#5555FF'>&amp;</font> <font color='#009900'>/*w*/</font>
    <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
    <b>{</b>
        <font color='#0000FF'>return</font> <font color='#BB00BB'>full_object_detection</font><font face='Lucida Console'>(</font>rect<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> Feature_extractor_type,
        <font color='#0000FF'>typename</font> Box_generator
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> scan_image_boxes<font color='#5555FF'>&lt;</font>Feature_extractor_type,Box_generator<font color='#5555FF'>&gt;</font>::
    <b><a name='get_feature_vector'></a>get_feature_vector</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> full_object_detection<font color='#5555FF'>&amp;</font> obj,
        feature_vector_type<font color='#5555FF'>&amp;</font> psi
    <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
    <b>{</b>
        <font color='#009900'>// make sure requires clause is not broken
</font>        <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font><font color='#BB00BB'>is_loaded_with_image</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                    psi.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#BB00BB'>get_num_dimensions</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                    obj.<font color='#BB00BB'>num_parts</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>,
            "<font color='#CC0000'>\t void scan_image_boxes::get_feature_vector()</font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t Invalid inputs were given to this function </font>"
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_loaded_with_image(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_loaded_with_image</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t psi.size():             </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> psi.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t get_num_dimensions():   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>get_num_dimensions</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t obj.num_parts():                            </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> obj.<font color='#BB00BB'>num_parts</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
            <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t this: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
            <font face='Lucida Console'>)</font>;



        <font color='#0000FF'>const</font> rectangle best_rect <font color='#5555FF'>=</font> <font color='#BB00BB'>get_best_matching_rect</font><font face='Lucida Console'>(</font>obj.<font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>const</font> rectangle mapped_rect <font color='#5555FF'>=</font> feats.<font color='#BB00BB'>image_to_feat_space</font><font face='Lucida Console'>(</font>best_rect<font face='Lucida Console'>)</font>.<font color='#BB00BB'>intersect</font><font face='Lucida Console'>(</font><font color='#BB00BB'>get_rect</font><font face='Lucida Console'>(</font>feats<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>mapped_rect.<font color='#BB00BB'>is_empty</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
            <font color='#0000FF'>return</font>;

        std::vector<font color='#5555FF'>&lt;</font>rectangle<font color='#5555FF'>&gt;</font> regions;
        <font color='#BB00BB'>get_feature_extraction_regions</font><font face='Lucida Console'>(</font>mapped_rect, regions<font face='Lucida Console'>)</font>;

        <font color='#009900'>// pull features out of all the boxes in regions.
</font>        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> j <font color='#5555FF'>=</font> <font color='#979000'>0</font>; j <font color='#5555FF'>&lt;</font> regions.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>j<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>const</font> rectangle rect <font color='#5555FF'>=</font> regions[j];

            <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> template_region_id <font color='#5555FF'>=</font> j;
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> offset <font color='#5555FF'>=</font> box_sizedims<font color='#5555FF'>*</font><font color='#979000'>2</font> <font color='#5555FF'>+</font> feats.<font color='#BB00BB'>get_num_dimensions</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>template_region_id;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>top</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; r <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> rect.<font color='#BB00BB'>bottom</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> rect.<font color='#BB00BB'>left</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; c <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> rect.<font color='#BB00BB'>right</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> feature_extractor_type::descriptor_type<font color='#5555FF'>&amp;</font> descriptor <font color='#5555FF'>=</font> <font color='#BB00BB'>feats</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font>;
                    <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> k <font color='#5555FF'>=</font> <font color='#979000'>0</font>; k <font color='#5555FF'>&lt;</font> descriptor.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>k<font face='Lucida Console'>)</font>
                    <b>{</b>
                        <font color='#BB00BB'>psi</font><font face='Lucida Console'>(</font>descriptor[k].first <font color='#5555FF'>+</font> offset<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font><font color='#5555FF'>=</font> descriptor[k].second;
                    <b>}</b>
                <b>}</b>
            <b>}</b>
        <b>}</b>

        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> width <font color='#5555FF'>=</font> best_rect.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font> height <font color='#5555FF'>=</font> best_rect.<font color='#BB00BB'>height</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>set_rowm</font><font face='Lucida Console'>(</font>psi, <font color='#BB00BB'>range</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,box_sizedims<font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>              <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>linpiece</font><font face='Lucida Console'>(</font>width,  <font color='#BB00BB'>linspace</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>, box_maxsize, box_sizedims<font color='#5555FF'>+</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>set_rowm</font><font face='Lucida Console'>(</font>psi, <font color='#BB00BB'>range</font><font face='Lucida Console'>(</font>box_sizedims,box_sizedims<font color='#5555FF'>*</font><font color='#979000'>2</font><font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>linpiece</font><font face='Lucida Console'>(</font>height, <font color='#BB00BB'>linspace</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>, box_maxsize, box_sizedims<font color='#5555FF'>+</font><font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<b>}</b>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_SCAN_IMAGE_bOXES_H__
</font>



</pre></body></html>